Stored Procedure Vs Function in MS SQL Server
Stored Procedure: A set of SQL Queries which are used to perform a specific task. A stored procedure can improve the performance of a database.
Function: A set of SQL Queries which can be used to pass parameters into and return values from it.
Difference:
Sl.No | Stored Procedure | Function |
1 | Compiled only once | Complies every time the function is invoked |
2 | Input and Output Parameters are permitted | Only input parameters are permitted |
3 | Need not necessarily return a value | A return value is necessary |
4 | A Function can be invoked by a Stored Procedure | A Stored Procedure cannot be invoked by a Function |
5 | SELECT,INSERT, UPDATE, DELETE cannot call a Stored Procedure | SELECT,INSERT, UPDATE, DELETE can call a Function |
Backend developer, Works on C#, SQL server lives in Manipal, Karnataka, India.